package org.fastsyncer.connector.framework;

import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.List;
import java.util.Map;

import org.fastsyncer.common.entity.BaseInfo;
import org.fastsyncer.common.entity.DatabaseConfig;
import org.springframework.jdbc.core.JdbcTemplate;

public abstract interface Database extends Connector {

    JdbcTemplate getJdbcTemplate(DatabaseConfig config);

    void close(JdbcTemplate jdbcTemplate);

    BaseInfo getBaseInfoConnector(DatabaseConfig config, String queryFilter);
    
    String getFilter(Map<String, List<Map<String, String>>> query);
    
    String getJdbcSQL(String opertion, DatabaseConfig config, List<Map<String, Object>> fileds, String queryFilter);

    StringBuilder getPageSQL(DatabaseConfig config, StringBuilder sql);
    
    String getJdbcQuartzRangeSQL(String table, String quartzFiled, String queryDatabaseFilter);
    
    String getJdbcQuartzAllSQL(String table, String quartzFiled, String queryDatabaseFilter);

    String getJdbcQuartzMaxSQL(String table, String quartzFiled);

    /**
     * 
     * @param ps
     *            参数构造器
     * @param fileds
     *            同步字段，例如[{name=ID, type=4}, {name=NAME, type=12}]
     * @param row
     *            同步字段对应的值，例如{ID=123, NAME=张三11}
     * @throws NumberFormatException
     * @throws SQLException
     */
    void batchRowsSetter(PreparedStatement ps, List<Map<String, Object>> fileds, Map<String, Object> row) throws Exception;

}
